   <!-- Content Bar Header -->
      <?php
      $auth = Auth::getAuth('current_user');
      $user_id = $auth['id'];
      $db = new Database();
      $fs = new functions;
      $search = new Search();

      
      $form_id = $fs->base_encode_decode("decrypt",$_GET['id']);
         if($auth['user_level_id']=="2"){
            echo $this->setInclude("contentHeader",null,null,null);
         }
         $forms = $db->query("SELECT * FROM tb_workspace WHERE id = {$db->escape($form_id)}","row");
         if($forms['is_active']==0){
            header("location:/");
         }
         $active_form = $db->query("SELECT * FROM tb_workspace WHERE id = {$db->escape($form_id)} AND is_active = 1","array");

         //get active fields
         $active_fields = functions::getFormFields($form_id);

         //set form authors
         $formPrivacy_authors = $search->getFormPrivacyUsers($forms['form_authors']);
	 
	 // Set form customized print
	 $form_json = json_decode($forms['form_json'],true);
	 $form_json_customized_print = $search->getFormPrivacyUsers(json_encode($form_json['form_json']['customized-print']));
	 

         $form_json = json_decode($forms['form_json']);
         $fields_header = $form_json->{'form_json'}->{'collected_data_header_info'}->{'listedchoice'};
         
         // Get Generate Print Save from the database tb_generate
            $getGeneratePrint = $db->query("SELECT * FROM tb_generate WHERE form_id={$db->escape($form_id)}","row");
            $getGeneratePrintNumrows = $db->query("SELECT * FROM tb_generate WHERE form_id={$db->escape($form_id)}","numrows");
      ?>
<div class="content_wrapper">
   <div class="mainContent">
      <div>
         <div class="widget" style="border-bottom:none !important">
            <div class="head">
                <div class="title_head">
                  <i class="icon-reorder"></i> <?php echo $forms['form_name']; ?>
               </div>
            </div>
            <div class="head" style="border-top: 1px solid #FFFFFF;border-bottom: 1px solid #FFFFFF;">
              
               <input type="text" class="display table-name" value="<?php echo $forms['form_table_name']; ?>">
               <input type="text" class="display form-name" value="<?php echo $forms['form_name']; ?>">
               <div class="form-header display"><?php echo json_encode($fields_header);  ?></div>
               <?php
               if(count($active_form)>0){
		  
                  if($formPrivacy_authors){
                     ?>
                     <a href="/workspace?view_type=request&formID=<?php echo $form_id ?>&requestID=0" class="btn-blueBtn" style="margin-top: 5px;margin-left: 5px;float: left;padding: 3px;font-weight: bold;padding-left: 10px;width: 90px;padding-right: 10px;font-size: 11px;">Create Request</a>
                     
                     <a class="btn-blueBtn" link-type ="import" link-form-id="<?php echo $form_id ?>" style="margin-top: 5px;margin-left: 5px;float: left;padding: 3px;font-weight: bold;padding-left: 10px;width: 38px;padding-right: 10px;font-size: 11px;">Import</a>
                     <?php
                  }
				  
					if($getGeneratePrintNumrows==0){
						      if($auth['user_level_id']=="1" || $auth['user_level_id']=="2" || $form_json_customized_print){
                     ?>
								<a href="/generate?view_type=edit&formID=<?php echo $form_id ?>" class="btn-blueBtn"  style="margin-top: 5px;margin-left: 5px;float: left;padding: 3px;font-weight: bold;padding-left: 10px;padding-right: 10px;font-size: 11px;">Customized Print</a>
                     <?php
							}
					}else{
						if($auth['user_level_id']=="1" || $auth['user_level_id']=="2" || $form_json_customized_print){
                     ?>
                        <a href="/generate?view_type=update&formID=<?php echo $getGeneratePrint['id']; ?>&printID=<?php echo $getGeneratePrint['form_id']; ?>" class="btn-blueBtn"  style="margin-top: 5px;margin-left: 5px;float: left;padding: 3px;font-weight: bold;padding-left: 10px;padding-right: 10px;font-size: 11px;">Update Print</a>
                     <?php
						}
					}
                    
               }
               ?>
               <input type="text" value="<?php echo $form_id ?>" id="form_id" class="display2">
               <input type="text" value="<?php echo $getGeneratePrint['id'] ?>" id="print_form_id" class="display"> 
               <div class="pull-right" style="margin:5px;">
                  <input type="button" class="btn-blueBtn search-requests" value="Go">
               </div>
               <div class="pull-right" style="margin:5px;">
                  <select class="input-select search-request-field display" style="margin-top:0px;width: 150px;margin-right:0px;padding-top: 5px;">
                     <option value="0">All</option>
                     <?php
                        foreach ($active_fields as $value) {
                           echo "<option value='". $value ."'>". $value ."</option>";
                        }
                     ?>
                     <!-- Static fields in table -->
                     <option value="TrackNo">Tracking Number</option>
                     <option value="Requestor">Requestor</option>
                     <option value="Processor">Processor</option>
                     <option value="Status">Status</option>
                  </select>
                  <?php
                     $strSql = "SELECT DISTINCT COLUMN_NAME FROM information_schema.columns where table_name = '". $forms['form_table_name'] ."' AND (DATA_TYPE = 'date' OR DATA_TYPE = 'datetime')";
                     $getdateFields = $db->query($strSql,"array");
                     $dateFields = array();
                     foreach ($getdateFields as  $value) {
                        if(in_array($value['COLUMN_NAME'], $active_fields)){
                           // echo $value['COLUMN_NAME'];
                           array_push($dateFields, $value['COLUMN_NAME']);
                        }
                     }
                  ?>
                  <select class="search-request-field_date display">
                     <?php
                        foreach ($dateFields as $value) {
                           echo "<option value='". $value ."'>". $value ."</option>";
                        }
                     ?>
                     <option value="DateCreated">DateCreated</option>
                  </select>
                  <input class="display search-request-field_filter_date_form" value="">
                  <input class="display search-request_date_from_form" value=''>
                  <input class="display search-request_date_to_form" value=''>
                  <button class="tip btn-basicBtn padding_5 cursor icon-cog advanceFilterDialog" style="margin-right:3px;height: 31px;width: 30px;" data-original-title="Advance Filter"></button>
               </div>
               <div class="pull-right" style="margin:5px;">
                  <input type="text" class="input-medium search-request-value" placeholder="Search">
               </div>
            </div>
            <div class="head saveFilterWrapper" style="height: 40px;">
               <div style="float:left;margin-left:8px">
                  <label style="margin-right: 10px;font-size: 11px;font-weight: bold;margin-right: 5px;">
                     Filtered Request :
                  </label>
                  <select class="input-select" id="loadRF" style="width:150px;text-align:center;margin-right:5px">
                     <option value="0" search_value="" search_field = "0">----------Select----------</option>
                     <?php
                        $strSql = "SELECT * FROM tbfilteredCategory WHERE user_id = '". $user_id ."' && form_id = '". $form_id ."'";
                        $getSaveFilter = $db->query($strSql,"array");
                        foreach ($getSaveFilter as $value) {
                           echo '<option value="'. $value['id'] .'" search_value="'.$value['search_value'].'" search_field = "'. $value['search_field'] .'" date_field="'. $value['date_field'] .'" date_from="'. $value['date_from'] .'" date_to="'. $value['date_to'] .'">'. $value['title'] .'</option>';
                        }
                     ?>
                  </select>
                  <button class="tip btn-basicBtn padding_5 cursor requestFilterSettings icon-trash" style="margin-right:3px;height: 31px;width: 30px;" data-original-title="Remove filter"></button>
               </div>
               <div class="filterConfirmationWrapper" style="float:right;margin-top: 5px;width: 50%;">
                  <label class="filterAction pull-left" style="margin-right: 10px;font-size: 11px;font-weight: bold;margin-right: 5px;display:none">
                     Do you want to save your filter?
                  </label>
                  <input type="button" class="btn-blueBtn filterAction pull-left" id="saveFC" value="Yes" style="margin-right:5px;display:none">
                  <input type="button" class="btn-basicBtn filterAction pull-left" id="cancelFC" value="No" style="margin-right:5px;display:none">
                  <input type="button" class="btn-blueBtn cancelLoadFRWrapper pull-right" id="cancelLoadFR" value="Cancel" style="margin-right:5px;display:none">
               </div>
            </div>
            <div class="request-wrapper" style="float: left;width: 100%;">
               <div class="hr" style="margin: 0;height: 3px"></div>
            </div>
         </div>
      </div>
   </div>
   <?php
      // Company Announcement
         echo $this->setInclude("company_announcement",null,null,null);
         
      // Starred
         echo $this->setInclude("starred",null,null,null);
         
      // My Request
         echo $this->setInclude("my_request",null,null,null);
   
   ?>
</div>
<script type="text/javascript" src="/js/functions/search.js"></script>
